<template>
  <div class="song-table">
    <div class="top-label">
      <span>序号</span>
      <span>歌曲</span>
      <span>歌手</span>
      <span>专辑</span>
      <span>时长</span>
    </div>
    <ul class="item" v-for="(item, index) in songList" :key="index">
      <li>
        <div class="number">
          <span>{{ 9 > index ? '0' + (index + 1) : index + 1 }}</span>
        </div>
        <div class="icon-wrapper">
          <i
            class="iconfont icon-play3"
            alt="播放"
            @click="playMusic(item)"
            v-if="songId !== item.id"
          ></i>
          <div class="audio-icon unselectable" v-else>
            <div class="column" style="animation-delay:-1.2s"></div>
            <div class="column"></div>
            <div class="column" style="animation-delay:-1.5s"></div>
            <div class="column" style="animation-delay:-0.9s"></div>
            <div class="column" style="animation-delay:-0.6s"></div>
          </div>
        </div>
        <div class="cover">
          <el-image :src="item.picUrl"> </el-image>
        </div>
      </li>
      <li>{{ item.name }}</li>
      <li>{{ item.artists }}</li>
      <li>{{ item.album.name }}</li>
      <li>{{ item.duration | filterPlayTime }}</li>
    </ul>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'song-table',
  props: {
    songList: {
      type: Array
    }
  },
  data () {
    return {
      isPlay: false
    }
  },
  methods: {
    playMusic (item) {
      this.$setSongId(item.id)
    }
  },
  computed: {
    ...mapState(['songId'])
  }
}
</script>
<style lang="less">
.song-table {
  width: 100%;
  margin-top: 20px;
  .top-label {
    display: flex;
    height: 50px;
    font-size: 14px;
    background-color: #63dbc1;
    color: #777;
    span {
      box-sizing: border-box;
      height: 100%;
      line-height: 50px;
      display: block;
      &:nth-child(1) {
        flex: 15%;
        padding-left: 40px;
      }
      &:nth-child(2) {
        flex: 35%;
      }
      &:nth-child(3) {
        flex: 20%;
      }
      &:nth-child(4) {
        flex: 20%;
      }
      &:nth-child(5) {
        flex: 10%;
        text-align: center;
        padding: 0 20px;
      }
    }
  }
  ul {
    display: flex;
    height: 50px;
    font-size: 14px;
    &:nth-child(2n-1) {
      background-color: #d7e0f0;
    }
    transition: background-color 0.6s;
    &:hover {
      background-color: #e8e9ed;
    }

    li {
      position: relative;
      line-height: 50px;
      &:nth-child(1) {
        flex: 15%;
        padding-left: 45px;
        display: flex;
        align-items: center;
        .cover {
          margin-left: 25px;
          width: 40px;
          height: 40px;
          border-radius: 4px;
          overflow: hidden;
          .el-image {
            width: 100%;
            height: 100%;
            display: block;
          }
        }
        .number {
          color: #999;
        }
        .icon-wrapper {
          margin-left: 25px;
          width: 30px;
          text-align: center;
          .icon-play3 {
            cursor: pointer;
            font-size: 24px;
            &:hover {
              color: tomato;
            }
          }
          .audio-icon {
            margin: 0 auto;
            width: 20px;
            height: 18px;
            min-width: 18px;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            overflow: hidden;
            .column {
              width: 2px;
              height: 100%;
              margin-left: 2px;
              background-color: #ff410f;
              -webkit-animation: play 0.9s linear infinite alternate;
              animation: play 0.9s linear infinite alternate;
            }
          }
        }
      }
      &:nth-child(2) {
        flex: 35%;
      }
      &:nth-child(3) {
        flex: 20%;
      }
      &:nth-child(4) {
        flex: 20%;
      }
      &:nth-child(5) {
        flex: 10%;
        text-align: center;
        padding: 0 20px;
      }
    }
  }
}
@keyframes play {
  0% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }

  100% {
    -webkit-transform: translateY(75%);
    transform: translateY(75%);
  }
}
</style>

/* */
